<template>
  <el-dialog v-model="visible" title="上传图片">
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      label-width="120px"
      status-icon
    >
      <el-form-item label="当前金额">
        {{ row.price }}
      </el-form-item>
      <el-form-item label="充值金额" prop="price">
        <el-input-number
          placeholder="价格"
          v-model="form.price"
          :precision="2"
          :min="0"
        >
        </el-input-number>
      </el-form-item>
    </el-form>
    <div></div>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="visible = false">取消</el-button>
        <el-button type="primary" @click="rechargeFn"> 确定 </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script type="link">
import { recharge } from '@/api/content.js'

export default {
  components: {
  },
  data () {
    return {
      visible: false,
      row: {},
      form: {
        id: '',
        price: ''
      },
      rules: {}
    };
  },
  mounted () {
  },
  methods: {
    // 显示弹窗
    showFn (row) {
      this.visible = true
      this.row = row
      this.form.id = row.id
      this.form.price = row.price
    },
    rechargeFn () {
      this.$refs.form.validate(valid => {
        if (valid) {
          recharge(this.form).then(res => {
            if (res.success) {
              this.$message({
                type: 'success',
                message: '充值成功!'
              })
              this.$emit('search')
              this.visible = false
            }
          })

        }
      })
    }
  }
};
</script>

<style scoped>
.unLoad {
  width: 1200px;
  margin: auto;
}
</style>
